﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace YXShop.Web.admin.product
{
    public partial class product_info_edit : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //YXShop.Common.PromptInfo.Popedom("001008001");

                if (Request.Form["Option"] != null && !Request.Form["Option"].Trim().Equals("")
                   && Request.Form["ID"] != null && !Request.Form["ID"].Trim().Equals(""))
                {
                    string types = Request.Form["Option"].Trim();
                    if (types == "ProductTypeId")
                    {
                        int cid = Convert.ToInt32(Request.Form["ID"].Trim());
                        this.GetProductTypeInfo(cid);
                    }
                    else if (types == "ProductPropertyId")
                    {
                        int productTypeId = Convert.ToInt32(Request.Form["ID"].Trim());
                        Response.Write(this.ProductProperty(productTypeId, ""));
                    }
                    else if (types == "ProductParameterId")
                    {
                        int productTypeId = Convert.ToInt32(Request.Form["ID"].Trim());
                        Response.Write(this.ProductParameter(productTypeId, ""));
                    }
                    else if (types == "ProductBrandId")
                    {
                        int productTypeId = Convert.ToInt32(Request.Form["ID"].Trim());
                        Response.Write(this.BrandList(productTypeId, string.Empty));
                    }
                    else if (types == "Sparepart")
                    {
                        int count = ChangeHope.WebPage.PageRequest.GetFormInt("Count");
                        Response.Write(this.Sparepart(count));
                    }
                    else if (types == "Specifications")
                    {
                        Response.Write(this.LoadSpecifications());
                    }
                    else if (types == "delAlbum")
                    {
                        string id = ChangeHope.WebPage.PageRequest.GetFormString("ID");
                        this.DelAlbum(id);
                    }
                    Response.End();
                    return;
                }
                else if (Request.Form["Option"] != null && !Request.Form["Option"].Trim().Equals("")
                && Request.Form["Name"] != null && !Request.Form["Name"].Trim().Equals(""))
                {
                    string Name = Request.Form["Name"].ToString();
                    string types = Request.Form["Option"].Trim();
                    if (types == "SearchProduct")
                    {
                        SearchRelatedProduct(Name);
                    }
                    else if (types == "SearchAtricle")
                    {
                        SearchRelatedArticle(Name);
                    }
                    Response.End();
                    return;
                }
                this.ltRelatingProductSelected.Text = "<select name=\"selPro_RelatingProIDSelect\" size=\"14\" multiple=\"multiple\" style=\"width: 98%\"></select>";
                this.ltRelatingArticle.Text = "<select name=\"selPro_RelatingArtIDSelect\" size=\"14\" multiple=\"multiple\" style=\"width: 98%\"></select>";
                this.litProductBrand.Text = this.BrandList(0, string.Empty);
                this.bindUnit(string.Empty);
                this.InitWebControl();
                this.bindProductType(0);

                int productId = ChangeHope.WebPage.PageRequest.GetInt("id");
                if (productId > 0)
                {
                    this.BindInfo(productId);
                }
                else
                {
                    this.litSpecifications.Text = this.LoadSpecifications();
                }

                int putoutType = ChangeHope.WebPage.PageRequest.GetQueryInt("putoutType");
                {
                    if (putoutType > -1)
                    {
                        this.HyperLink1.NavigateUrl = "product_list.aspx?q_PutoutType=" + putoutType + "";
                        this.HyperLink2.NavigateUrl = "product_list.aspx?q_PutoutType=" + putoutType + "";
                    }
                }
                if (ViewState["ID"] != null)
                {
                    YXShop.Common.PromptInfo.Popedom("001008004", "对不起，您没有编辑权限");
                }
                else
                {
                    YXShop.Common.PromptInfo.Popedom("001008002", "对不起，您没有新增权限");
                }
            }
        }
        #region 验证
        /// <summary>
        /// 验证
        /// </summary>
        private void InitWebControl()
        {
            YXShop.Common.SysParameter sp = new YXShop.Common.SysParameter();
            if (sp.IsCloseStation)
            {
                this.spanArea.Style.Value = "display:";
            }
            this.txtProductClass.Attributes.Add("readonly", "readonly");
            this.txtProductClass.Attributes.Add("onclick", "selectFile('Product_info_class',new Array(" + this.hfcid.ClientID + "," + this.txtProductClass.ClientID + "),310,450,'" + sp.DummyPaht + "');");
            this.txtArea.Attributes.Add("readonly", "readonly");
            this.txtArea.Attributes.Add("onclick", "selectFile('Area',new Array(" + this.hfid.ClientID + "," + this.txtArea.ClientID + "),310,450,'" + sp.DummyPaht + "');");
            ChangeHope.WebPage.WebControl.Validate(this.txtProductName, "输入商品名称的名称", "isnull", "必填", "该项为必填项");
            ChangeHope.WebPage.WebControl.Validate(this.txtWeiht, "输入商品重量", "ifisfloat", "选填", "该项为必填项");
            ChangeHope.WebPage.WebControl.Validate(this.txtUpCount, "前台商品的可否购买状态取决于您的商品上架数量，可以小于或等于商品库存，请输入正整数", "ifisint", "选填", "该项为必须为数字");
            ChangeHope.WebPage.WebControl.SetDate(this.txtFilingTime);
            ChangeHope.WebPage.WebControl.SetDate(this.txtDownTime);
            ChangeHope.WebPage.WebControl.Validate(this.txtFilingTime, "商品在前台展示的开始时间", "ifisnull", "选填", "该项为选填项");
            ChangeHope.WebPage.WebControl.Validate(this.txtDownTime, "商品在前台展示的结束时间", "ifisnull", "选填", "该项为选填项");
            ChangeHope.WebPage.WebControl.Validate(this.txtMarketPrice, "输入市场价格将作为商城价格与市场价格进行对比", "ifisfloat", "选填", "该项为必须为数字");
            ChangeHope.WebPage.WebControl.Validate(this.txtCostPrice, "输入成本价将方便后台管理查看,不会在前台让用户看到该价格", "ifisfloat", "选填", "该项为必须为数字");
            ChangeHope.WebPage.WebControl.Validate(this.txtDonateInteg, "用户购买该商品否可以获得的积分数，为0表示购买该商品不赠送积分", "ifisint", "选填", "该项只能输入数字");

            int putoutType = ChangeHope.WebPage.PageRequest.GetQueryInt("putoutType");
            
            if (putoutType == 2)
            {
                trchklstState.Visible = false;
                trContentPageTemplate.Visible = false;
                trchklistMarking.Visible = false;
                TabTitle6.Visible = false;
                TabTitle7.Visible = false;
                TabTitle8.Visible = false;
                tab6.Visible = false;
                tab7.Visible = false;
                tab8.Visible = false;
            }


            this.txtContentPageTemplate.Attributes.Add("onclick", "GetFile(this)");
            this.txtContentPageTemplate.Attributes.Add("readonly", "readonly");
            this.GetFileList();
            this.Form.Attributes.Add("onsubmit", "return CheckForm()");
        }
        #endregion

        #region 模板
        private void GetFileList()
        {
            /*
            修改人：ym
            修改时间：2009-8-26
            修改内容：添加
             */
            YXShop.Common.SysParameter sp = new YXShop.Common.SysParameter();
            ChangeHope.Common.FileHelper file = new ChangeHope.Common.FileHelper();

            StringBuilder filelist = new StringBuilder();
                file.rootUrl = Server.MapPath("~/" + sp.WebSiteTemplatePath);
            file.listFiles(file.rootUrl, 0);
            filelist.AppendLine("<script type=\"text/javascript\">");
            filelist.AppendLine("d = new dTree('d');");
            filelist.AppendLine("d.add(0,-1,'请选择模版(点击选择模版设为默认)','javascript: GetFileUrl();');");
            filelist.AppendLine(file.fileTree.ToString());
            filelist.AppendLine("document.write(d);");
            filelist.AppendLine("$(\"fileLists\").style.visibility=\"hidden\";");
            filelist.AppendLine("</script>");
            this.ltlFileList.Text = filelist.ToString();
            file = null;
        }
        #endregion

        #region 加载品牌
        /// <summary>
        /// 修改商品加载品牌
        /// </summary>
        /// <param name="CID"></param>
        /// <param name="BID"></param>
        protected string BrandList(int productTypeId, string bid)
        {
            YXShop.BLL.Product.ProductBrand bll = new YXShop.BLL.Product.ProductBrand();
            List<YXShop.Model.Product.ProductBrand> list = null;
            if (productTypeId > 0)
            {
                YXShop.BLL.Product.ProductType ptbll = new YXShop.BLL.Product.ProductType();
                YXShop.Model.Product.ProductType ptmodel = ptbll.GetModel(productTypeId);
                if (ptmodel != null)
                {
                    if (ptmodel.RelevanceBrand != "" && ptmodel.RelevanceBrand != string.Empty)
                    {
                        list = bll.GetDTList(ptmodel.RelevanceBrand);
                    }
                }
            }
            else
            {
                list = bll.GetCommonTypes();
            }
            StringBuilder shtml = new StringBuilder();
            shtml.Append("<select name=\"selBrand\" id=\"selBrand\">");
            shtml.Append("<option value=\"0\">--选择品牌--</option>");
            if (list!=null&&list.Count > 0)
            {
                foreach (Model.Product.ProductBrand brand in list)
                {
                    shtml.Append("<option value=\"" + brand.ID + "\"");
                    if (brand.ID.ToString() == bid)
                    {
                        shtml.Append(" selected=\"selected\" ");
                    }
                    shtml.Append(">" + brand.Name + "</option>");
                }
            }
            shtml.Append("</select>");
            return shtml.ToString();
        }
        #endregion

        #region 加载商品单位
        protected void bindUnit(string unit)
        {
            YXShop.BLL.Product.ProductUnit bll = new YXShop.BLL.Product.ProductUnit();
            ChangeHope.DataBase.DataByPage dataPage = bll.GetList();
            StringBuilder shtml = new StringBuilder();
            shtml.Append("<select name=\"selUnit\" id=\"selUnit\">");
            shtml.Append("<option value=\"0\" selected=\"selected\">--选择单位--</option>");
            if (dataPage.DataReader != null)
            {

                while (dataPage.DataReader.Read())
                {
                    if (dataPage.DataReader["name"].ToString() == unit)
                    {
                        shtml.Append("<option value=\"" + dataPage.DataReader["name"].ToString() + "\" selected=\"selected\">" + dataPage.DataReader["name"].ToString() + "</option>");
                    }
                    else
                    {
                        shtml.Append("<option value=\"" + dataPage.DataReader["name"].ToString() + " \">" + dataPage.DataReader["name"].ToString() + "</option>");
                    }
                }
                dataPage.Dispose();
                dataPage = null;
            }

            shtml.Append("</select>");
            this.litUnit.Text = shtml.ToString();
        }
        #endregion

        #region 加载商品类型
        protected void bindProductType(int TypeId)
        {
            YXShop.BLL.Product.ProductType bll = new YXShop.BLL.Product.ProductType();
            List<YXShop.Model.Product.ProductType> list = bll.GetAllByWhere("");
            StringBuilder shtml = new StringBuilder();
            shtml.Append("<select name=\"selProductType\" id=\"selProductType\" onchange=\"ProductTypeId(this.value)\" class=\"inputCSS\">");
            shtml.Append("<option value=\"0\">通用商品类型</option>");
            if (list.Count > 0)
            {
                foreach (YXShop.Model.Product.ProductType type in list)
                {
                    shtml.Append("<option value=\"" + type.Id + "\"");
                    if (type.Id == TypeId)
                    {
                        shtml.Append(" selected=\"selected\" ");
                    }
                    shtml.Append(">" + type.TypeName + "</option>");
                }
            }
            shtml.Append("</select>");
            this.litProductType.Text=shtml.ToString();
        }
        #endregion

        #region 跟据商品分类ID查询商品类型ID
        private void GetProductTypeInfo(int cid)
        {
            YXShop.BLL.Product.Productclass bll = new YXShop.BLL.Product.Productclass();
            YXShop.Model.Product.Productclass model = bll.GetModelID(cid);
            if (model != null)
            {
                Response.Write(model.ProductTypeId.ToString());
            }
            else
            {
                Response.Write("");
            }
        }
        #endregion

        #region 加载商品属性
        private string ProductProperty(int productTypeId,string propertyValue)
        {
            StringBuilder shtml = new StringBuilder();
            YXShop.BLL.Product.ProductType bll = new YXShop.BLL.Product.ProductType();
            List<YXShop.Model.Product.ProductTypeProperty> list = bll.GetProductPropertyAllByWhere(productTypeId, "");
            if (list.Count > 0)
            {
                Regex groupSpace = new Regex(@"gro_space");
                Regex valueSpace = new Regex(@"va_space");
                string[] strPropertyValue = null;
                if (!string.IsNullOrEmpty(propertyValue))
                {
                    strPropertyValue = groupSpace.Split(propertyValue);
                }
                shtml.Append("<table class=\"form_table_input\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">");
                foreach (YXShop.Model.Product.ProductTypeProperty property in list)
                {
                    switch (property.PropertyType)
                    {
                        case 1:
                            #region 从下拉列表中选择
                            shtml.Append("<tr>");
                            shtml.Append("<td class=\"form_table_input_info\">");
                            shtml.Append(property.PropertyName + "：");
                            shtml.Append("</td>");
                            shtml.Append("<td>");
                            shtml.Append("<select name=\"property" + property.ID + "\" id=\"property" + property.ID + "\">");
                            shtml.Append("<option value='' selected=\"selected\">--请选择" + property.PropertyName + "--</option>");
                            foreach (string pv in property.PropertyValue.Split('\n'))
                            {
                                shtml.Append("<option value=\"" + pv + "\"");
                                if (strPropertyValue != null)
                                {
                                    foreach (string val in strPropertyValue)
                                    {
                                        string[] temp = valueSpace.Split(val);
                                        if (temp[0] == property.ID.ToString() && temp[1].Replace("\r", "") == pv.Replace("\r", ""))
                                        {
                                            shtml.Append(" selected=\"selected\" ");
                                        }
                                    }
                                }
                                shtml.Append(">" + pv + "</option>");
                            }
                            shtml.Append("</select>");
                            shtml.Append("</td>");
                            shtml.Append("<td>");
                            shtml.Append("<input type=\"hidden\" name=\"ProPropertyID\" value=\"" + property.ID.ToString() + "\" />");
                            shtml.Append("<div class=\"msgNormal\">请选择" + property.PropertyName + "</div>");
                            shtml.Append("</td>");
                            shtml.Append("</tr>");
                            break;
                            #endregion
                        case 2:
                            #region 单选
                            shtml.Append("<tr>");
                            shtml.Append("<td class=\"form_table_input_info\">");
                            shtml.Append(property.PropertyName + "：");
                            shtml.Append("</td>");
                            shtml.Append("<td>");
                            foreach (string pv in property.PropertyValue.Split('\n'))
                            {
                                shtml.Append("<input type=\"radio\" name=\"property" + property.ID.ToString() + "\" value=\"" + pv + "\"");
                                if (strPropertyValue != null)
                                {
                                    foreach (string val in strPropertyValue)
                                    {
                                        string[] temp = valueSpace.Split(val);
                                        if (temp[0] == property.ID.ToString() && temp[1].Replace("\r", "").Equals(pv.Replace("\r", "")))
                                        {
                                            shtml.Append(" checked=\"checked\" ");
                                            break;
                                        }
                                    }
                                }
                                shtml.Append(" />" + pv + "");
                            }

                            shtml.Append("</td>");
                            shtml.Append("<td>");
                            shtml.Append("<input type=\"hidden\" name=\"ProPropertyID\" value=\"" + property.ID.ToString() + "\" />");
                            shtml.Append("<div class=\"msgNormal\">请选择" + property.PropertyName + "</div>");
                            shtml.Append("</td>");
                            shtml.Append("</tr>");
                            break;
                            #endregion
                        case 3:
                            #region 多选
                            shtml.Append("<tr>");
                            shtml.Append("<td class=\"form_table_input_info\">");
                            shtml.Append(property.PropertyName + "：");
                            shtml.Append("</td>");
                            shtml.Append("<td>");
                            foreach (string pv in property.PropertyValue.Split('\n'))
                            {
                                shtml.Append("<input type=\"checkbox\" name=\"property" + property.ID.ToString() + "\" value=\"" + pv + "\"");
                                if (strPropertyValue != null)
                                {
                                    foreach (string val in strPropertyValue)
                                    {
                                        string[] temp = valueSpace.Split(val);
                                        if (temp.Length > 1)
                                        {
                                            string[] temp2 = temp[1].Split(',');
                                            for (int k = 0; k < temp2.Length; k++)
                                            {
                                                if (temp[0] == property.ID.ToString() && temp2[k].Replace("\r", "").Equals(pv.Replace("\r", "")))
                                                {
                                                    shtml.Append(" checked=\"checked\" ");
                                                }
                                            }
                                        }
                                    }
                                }
                                shtml.Append(" />" + pv + "");

                            }
                            shtml.Append("</td>");
                            shtml.Append("<td>");
                            shtml.Append("<input type=\"hidden\" name=\"ProPropertyID\" value=\"" + property.ID.ToString() + "\" />");
                            shtml.Append("<div class=\"msgNormal\">请选择" + property.PropertyName + "</div>");
                            shtml.Append("</td>");
                            shtml.Append("</tr>");
                            break;
                            #endregion
                        case 4:
                            #region 单行文本
                            shtml.Append("<tr>");
                            shtml.Append("<td class=\"form_table_input_info\">");
                            shtml.Append(property.PropertyName.ToString() + "：");
                            shtml.Append("</td>");
                            shtml.Append("<td>");
                            shtml.Append("<input type=\"text\" id=\"property" + property.ID.ToString() + "\" name=\"property" + property.ID.ToString() + "\"");
                            if (strPropertyValue != null)
                            {
                                foreach (string val in strPropertyValue)
                                {
                                    string[] temp = valueSpace.Split(val);
                                    if (temp[0] == property.ID.ToString())
                                    {
                                        shtml.Append(" value=\"" + temp[1] + "\" ");
                                    }
                                }
                            }
                            shtml.Append("  />");
                            shtml.Append("</td>");
                            shtml.Append("<td><input type=\"hidden\" name=\"ProPropertyID\" value=\"" + property.ID.ToString() + "\" />");
                            shtml.Append("<div class=\"msgNormal\">请输入" + property.PropertyName + "</div>");
                            shtml.Append("</td>");
                            shtml.Append("</tr>");
                            break;
                            #endregion
                        case 5:
                            #region 多行文本
                            string strValue = string.Empty;
                            shtml.Append("<tr>");
                            shtml.Append("<td class=\"form_table_input_info\">");
                            shtml.Append(property.PropertyName + "：");
                            shtml.Append("</td>");
                            shtml.Append("<td>");
                            shtml.Append("<textarea name=\"property" + property.ID.ToString() + "\" id=\"property" + property.ID.ToString() + "\" cols=\"23\" rows=\"6\"");
                            if (strPropertyValue != null)
                            {
                                foreach (string val in strPropertyValue)
                                {
                                    string[] temp = valueSpace.Split(val);
                                    if (temp[0] == property.ID.ToString())
                                    {
                                        strValue = temp[1];
                                    }
                                }
                            }
                            shtml.Append(">");
                            if (!string.IsNullOrEmpty(strValue))
                            {
                                shtml.Append(strValue);
                            }
                            shtml.Append("</textarea>");
                            shtml.Append("</td>");
                            shtml.Append("<td><input type=\"hidden\" name=\"ProPropertyID\" value=\"" + property.ID.ToString() + "\" />");
                            shtml.Append("<div class=\"msgNormal\">请输入" + property.PropertyName + "</div>");
                            shtml.Append("</td>");
                            shtml.Append("</tr>");
                            break;
                            #endregion
                        default:
                            break;
                    }
                }
                shtml.Append("</table>");
            }
            return shtml.ToString();
        }
        #endregion

        #region 加载商品参数
        private string ProductParameter(int productTypeId, string parameterValue)
        {
            StringBuilder shtml=new StringBuilder();
            YXShop.BLL.Product.ProductType bll = new YXShop.BLL.Product.ProductType();
            List<YXShop.Model.Product.ProductTypeParameter> typeList = bll.GetProductParameterAllByWhere(productTypeId, " 1=1 and ParID=0");
            if (typeList.Count > 0)
            {
                Regex groupSpace = new Regex(@"t_space");
                Regex tIdSpace = new Regex(@"tid_space");
                string[] strParameterGroup = null;
                if (!string.IsNullOrEmpty(parameterValue))
                {
                    strParameterGroup = groupSpace.Split(parameterValue);
                }

                shtml.Append("<table class=\"form_table_input\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">");
                foreach (YXShop.Model.Product.ProductTypeParameter parameterType in typeList)
                {
                    List<YXShop.Model.Product.ProductTypeParameter> list = bll.GetProductParameterAllByWhere(productTypeId, " 1=1 and ParID=" + parameterType.ID);
                    if (list.Count > 0)
                    {
                        string parTypeId = parameterType.ID.ToString();
                        shtml.Append("<tr>");
                        shtml.Append("<td colspan='3' style='font-weight:bold;height:24px;background-color:#F5F6F4'>" + parameterType.ParameterName + "<input type=\"hidden\" name=\"ProParameterTypeID\" value=\"" + parTypeId + "\" /></td>");
                        shtml.Append("</tr>");
                        foreach (YXShop.Model.Product.ProductTypeParameter parameter in list)
                        {

                            switch (parameter.ParameterType)
                            {
                                case 1:
                                    #region 从下拉列表中选择
                                    shtml.Append("<tr>");
                                    shtml.Append("<td class=\"form_table_input_info\">");
                                    shtml.Append(parameter.ParameterName + "：");
                                    shtml.Append("</td>");
                                    shtml.Append("<td>");
                                    shtml.Append("<select name=\"parameter" + parTypeId + parameter.ID + "\" id=\"parameter" + parTypeId + parameter.ID + "\">");
                                    shtml.Append("<option value='' selected=\"selected\">--请选择" + parameter.ParameterName + "--</option>");
                                    foreach (string pv in parameter.ParameterValue.Split('\n'))
                                    {
                                        shtml.Append("<option value=\"" + pv + "\"");
                                        if (strParameterGroup != null)
                                        {
                                            foreach (string pg in strParameterGroup)
                                            {
                                                string[] strParameterValue = tIdSpace.Split(pg);
                                                if (strParameterValue[0] == parTypeId)
                                                {
                                                    if (strParameterValue[1] != null)
                                                    {
                                                        string[] strParValue = strParameterValue[1].Split('|');
                                                        foreach (string val in strParValue)
                                                        {
                                                            string[] temp = val.Split(',');
                                                            if (temp[0] == parameter.ID.ToString() && temp[1].Replace("\r", "") == pv.Replace("\r", ""))
                                                            {
                                                                shtml.Append(" selected=\"selected\" ");
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        shtml.Append(">" + pv + "</option>");
                                    }
                                    shtml.Append("</select>");
                                    shtml.Append("</td>");
                                    shtml.Append("<td>");
                                    shtml.Append("<input type=\"hidden\" name=\"ProParameterID" + parTypeId + "\" value=\"" + parameter.ID.ToString() + "\" />");
                                    shtml.Append("<div class=\"msgNormal\">请选择" + parameter.ParameterName + "</div>");
                                    shtml.Append("</td>");
                                    shtml.Append("</tr>");
                                    break;
                                    #endregion
                                case 2:
                                    #region 单选
                                    shtml.Append("<tr>");
                                    shtml.Append("<td class=\"form_table_input_info\">");
                                    shtml.Append(parameter.ParameterName + "：");
                                    shtml.Append("</td>");
                                    shtml.Append("<td>");
                                    foreach (string pv in parameter.ParameterValue.Split('\n'))
                                    {
                                        shtml.Append("<input type=\"radio\" name=\"parameter" + parTypeId + parameter.ID.ToString() + "\" value=\"" + pv + "\"");
                                        if (strParameterGroup != null)
                                        {
                                            foreach (string pg in strParameterGroup)
                                            {
                                                string[] strParameterValue = tIdSpace.Split(pg);
                                                if (strParameterValue[0] == parTypeId)
                                                {
                                                    if (strParameterValue[1] != null)
                                                    {
                                                        string[] strParValue = strParameterValue[1].Split('|');
                                                        foreach (string val in strParValue)
                                                        {
                                                            string[] temp = val.Split(',');
                                                            if (temp[0] == parameter.ID.ToString() && temp[1].Replace("\r", "").Equals(pv.Replace("\r", "")))
                                                            {
                                                                shtml.Append(" checked=\"checked\" ");
                                                                break;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        shtml.Append(" />" + pv + "");
                                    }

                                    shtml.Append("</td>");
                                    shtml.Append("<td>");
                                    shtml.Append("<input type=\"hidden\" name=\"ProParameterID" + parTypeId + "\" value=\"" + parameter.ID.ToString() + "\" />");
                                    shtml.Append("<div class=\"msgNormal\">请选择" + parameter.ParameterName + "</div>");
                                    shtml.Append("</td>");
                                    shtml.Append("</tr>");
                                    break;
                                    #endregion
                                case 3:
                                    #region 多选
                                    shtml.Append("<tr>");
                                    shtml.Append("<td class=\"form_table_input_info\">");
                                    shtml.Append(parameter.ParameterName + "：");
                                    shtml.Append("</td>");
                                    shtml.Append("<td>");
                                    foreach (string pv in parameter.ParameterValue.Split('\n'))
                                    {
                                        shtml.Append("<input type=\"checkbox\" name=\"parameter" + parTypeId + parameter.ID.ToString() + "\" value=\"" + pv + "\"");
                                        if (strParameterGroup != null)
                                        {
                                            foreach (string pg in strParameterGroup)
                                            {
                                                string[] strParameterValue = tIdSpace.Split(pg);
                                                if (strParameterValue[0] == parTypeId)
                                                {
                                                    if (strParameterValue[1] != null)
                                                    {
                                                        string[] strParValue = strParameterValue[1].Split('|');
                                                        foreach (string val in strParValue)
                                                        {
                                                            string[] temp = val.Split(',');
                                                            for (int k = 0; k < temp.Length; k++)
                                                            {
                                                                if (temp[0] == parameter.ID.ToString() && temp[k].Replace("\r", "").Equals(pv.Replace("\r", "")))
                                                                {
                                                                    shtml.Append(" checked=\"checked\" ");
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        shtml.Append(" />" + pv + "");

                                    }
                                    shtml.Append("</td>");
                                    shtml.Append("<td>");
                                    shtml.Append("<input type=\"hidden\" name=\"ProParameterID" + parTypeId + "\" value=\"" + parameter.ID.ToString() + "\" />");
                                    shtml.Append("<div class=\"msgNormal\">请选择" + parameter.ParameterName + "</div>");
                                    shtml.Append("</td>");
                                    shtml.Append("</tr>");
                                    break;
                                    #endregion
                                case 4:
                                    #region 单行文本
                                    shtml.Append("<tr>");
                                    shtml.Append("<td class=\"form_table_input_info\">");
                                    shtml.Append(parameter.ParameterName.ToString() + "：");
                                    shtml.Append("</td>");
                                    shtml.Append("<td>");
                                    shtml.Append("<input type=\"text\" id=\"parameter" + parTypeId + parameter.ID.ToString() + "\" name=\"parameter" + parTypeId + parameter.ID.ToString() + "\"");
                                    if (strParameterGroup != null)
                                    {
                                        foreach (string pg in strParameterGroup)
                                        {
                                            string[] strParameterValue = tIdSpace.Split(pg);
                                            if (strParameterValue[0] == parTypeId)
                                            {
                                                if (strParameterValue[1] != null)
                                                {
                                                    string[] strParValue = strParameterValue[1].Split('|');
                                                    foreach (string val in strParValue)
                                                    {
                                                        string[] temp = val.Split(',');
                                                        if (temp[0] == parameter.ID.ToString())
                                                        {
                                                            shtml.Append(" value=\"" + temp[1] + "\" ");
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    shtml.Append("  />");
                                    shtml.Append("</td>");
                                    shtml.Append("<td><input type=\"hidden\" name=\"ProParameterID" + parTypeId + "\" value=\"" + parameter.ID.ToString() + "\" />");
                                    shtml.Append("<div class=\"msgNormal\">请输入" + parameter.ParameterName + "</div>");
                                    shtml.Append("</td>");
                                    shtml.Append("</tr>");
                                    break;
                                    #endregion
                                case 5:
                                    #region 多行文本
                                    string strValue = string.Empty;
                                    shtml.Append("<tr>");
                                    shtml.Append("<td class=\"form_table_input_info\">");
                                    shtml.Append(parameter.ParameterName + "：");
                                    shtml.Append("</td>");
                                    shtml.Append("<td>");
                                    shtml.Append("<textarea name=\"parameter" + parTypeId + parameter.ID.ToString() + "\" id=\"parameter" + parTypeId + parameter.ID.ToString() + "\" cols=\"23\" rows=\"6\"");
                                    if (strParameterGroup != null)
                                    {
                                        foreach (string pg in strParameterGroup)
                                        {
                                            string[] strParameterValue = tIdSpace.Split(pg);
                                            if (strParameterValue[0] == parTypeId)
                                            {
                                                if (strParameterValue[1] != null)
                                                {
                                                    string[] strParValue = strParameterValue[1].Split('|');
                                                    foreach (string val in strParValue)
                                                    {
                                                        string[] temp = val.Split(',');
                                                        if (temp[0] == parameter.ID.ToString())
                                                        {
                                                            strValue = temp[1];
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    shtml.Append(">");
                                    if (!string.IsNullOrEmpty(strValue))
                                    {
                                        shtml.Append(strValue);
                                    }
                                    shtml.Append("</textarea>");
                                    shtml.Append("</td>");
                                    shtml.Append("<td><input type=\"hidden\" name=\"ProParameterID" + parTypeId + "\" value=\"" + parameter.ID.ToString() + "\" />");
                                    shtml.Append("<div class=\"msgNormal\">请输入" + parameter.ParameterName + "</div>");
                                    shtml.Append("</td>");
                                    shtml.Append("</tr>");
                                    break;
                                    #endregion
                                default:
                                    break;
                            }
                        }
                    }
                    
                }
                shtml.Append("</table>");
            }
            return shtml.ToString();
        }
        #endregion

        #region 加载配件
        private string Sparepart(int sparepartCount)
        {
            YXShop.Common.SysParameter sp = new YXShop.Common.SysParameter();
            StringBuilder shtml = new StringBuilder();
            shtml.Append("<div id='SparepartGroupCount" + sparepartCount + "'>");
            shtml.Append("<table class=\"form_table_input\" style='border-top:solid 2px #BAC9C6;' border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">");
            shtml.Append("<tr>");
            shtml.Append("<td class=\"form_table_input_info\">配件组名称：</td>");
            shtml.Append("<td>");
            shtml.Append("<input type=\"hidden\" name=\"hfSparepartId\" id=\"hfSparepartId\" value=\"" + sparepartCount + "\"/>");
            shtml.Append("<input id=\"txtSparepartName" + sparepartCount + "\" name=\"txtSparepartName" + sparepartCount + "\" />");
            shtml.Append("</td>");
            shtml.Append("<td class=\"page_button\">");
            shtml.Append("<a ID=\"HyperLink5\" Class=\"inputbutton\" href=\"javascript:DelSparepartGroup(" + sparepartCount + ")\" Width=\"65px\" Height=\"24px\" onMouseOver=\"javascript:document.getElementById(this.id).className='inputbutton_a'\" onMouseOut=\"javascript:document.getElementById(this.id).className='inputbutton'\">删除此配件</a>");
            shtml.Append("</td>");
            shtml.Append("</tr>");
            shtml.Append("<tr>");
            shtml.Append("<td class=\"form_table_input_info\">最小购买量：</td>");
            shtml.Append("<td>");
            shtml.Append("<input id=\"txtMinCount" + sparepartCount + "\" name=\"txtMinCount" + sparepartCount + "\" class=\"short_input\" />");
            shtml.Append(" </td>");
            shtml.Append(" <td>");
            shtml.Append(" <div class=\"msgNormal\">请输入最小购买量</div>");
            shtml.Append(" </td>");
            shtml.Append("</tr>");
            shtml.Append("<tr>");
            shtml.Append("<td class=\"form_table_input_info\">最大购买量：</td>");
            shtml.Append("<td>");
            shtml.Append("<input id=\"txtMaxCount" + sparepartCount + "\" name=\"txtMaxCount" + sparepartCount + "\" class=\"short_input\" />");
            shtml.Append("</td>");
            shtml.Append("<td>");
            shtml.Append(" <div class=\"msgNormal\">请输入最大购买量</div>");
            shtml.Append("</td>");
            shtml.Append("</tr>");
            shtml.Append("<tr>");
            shtml.Append("<td class=\"form_table_input_info\">配件优惠：</td>");
            shtml.Append("<td>");
            shtml.Append("<input name=\"SparepartFavourable" + sparepartCount + "\" type=\"radio\" value='0' checked=\"checked\"/>优惠某个折扣");
            shtml.Append("<input name=\"SparepartFavourable" + sparepartCount + "\" type=\"radio\" value='1' />优惠一定金额");
            shtml.Append("</td>");
            shtml.Append("<td>");
            shtml.Append("<div class=\"msgNormal\">请选择配件优惠类型。</div>");
            shtml.Append("</td>");
            shtml.Append(" </tr>");
            shtml.Append("<tr>");
            shtml.Append("<td class=\"form_table_input_info\">优惠额度：</td>");
            shtml.Append("<td>");
            shtml.Append("<input id=\"txtFavourablePrice" + sparepartCount + "\" name=\"txtFavourablePrice" + sparepartCount + "\" class=\"short_input\" />");
            shtml.Append("</td>");
            shtml.Append("<td>");
            shtml.Append(" <div class=\"msgNormal\">(无优惠可不填；优惠9折就输入0.9，优惠100元就输入100)</div>");
            shtml.Append("</td>");
            shtml.Append(" </tr>");
            shtml.Append("<tr>");
            shtml.Append("<td class=\"form_table_input_info\">添加配件商品：</td>");
            shtml.Append("<td colspan=\"3\">");
            shtml.Append("<table width=\"100%\" style=\" background-color:#F5F5F5\" cellpadding=\"1\" cellspacing=\"1\">");
            shtml.Append("<tr style=\"background-color:#EBEDE8; height:22px;font-weight:bold;\">");
            shtml.Append("<td width=\"10%\">");
            shtml.Append("<a href=\"javascript:showPath('ProductSparepart',document.getElementById('address'),'选择配件',640,350,'" + sp.DummyPaht + "'," + sparepartCount + ");\">添加商品</a>");
            shtml.Append("</td>");
            shtml.Append("<td width=\"40%\">商品名称</td>");
            shtml.Append("<td width=\"50%\">物品描述</td>");
            shtml.Append("</tr>");
            shtml.Append("</table>");
            shtml.Append("<div id='SparepartProduct"+sparepartCount+"'>");
            shtml.Append("</div>");
            shtml.Append("</td>");
            shtml.Append("</tr>");
            shtml.Append("<tr><td colspan='3'><input type=\"hidden\" name=\"hfProductSparepartID" + sparepartCount + "\" id=\"hfProductSparepartID" + sparepartCount + "\" /></td></tr>");
            shtml.Append("</table>");
            shtml.Append("</div>");
            return shtml.ToString();
        }
        #endregion

        #region 加载规格
        private string LoadSpecifications()
        {
            return this.Specifications(string.Empty, string.Empty, string.Empty);
        }
        private string Specifications(string Stock, string Integral,string Price)
        {
            YXShop.Common.SysParameter sp = new YXShop.Common.SysParameter();
            StringBuilder shtml = new StringBuilder();
            shtml.Append("<table class=\"form_table_input\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">");
            shtml.Append("<tr>");
            shtml.Append("<td class=\"form_table_input_info\">规格：</td>");
            shtml.Append("<td colspan=\"2\" class=\"page_button\">");
            shtml.Append(" 如果此商品有多种规格，可点此");
            shtml.Append("<a id=\"addSpecifications\"  class=\"inputbutton\" href=\"javascript:StartSP();showPath('StartSpecifications',document.getElementById('SpecificationsAddress'),'开启规格',650,250,'" + sp.DummyPaht + "');\">开启规格</a>");
            shtml.Append("</td>");
            shtml.Append("</tr>");
            shtml.Append("<tr>");
            shtml.Append("<td class=\"form_table_input_info\">库存：</td>");
            shtml.Append("<td>");
            shtml.Append("<input type=\"text\" id=\"txtStock\" name=\"txtStock\" value=\""+Stock+"\"/>");
            shtml.Append("</td>");
            shtml.Append("<td>");
            shtml.Append("<div class=\"msgNormal\" id=\"divStock\">请输入库存</div>");
            shtml.Append("</td>");
            shtml.Append("</tr>");
            shtml.Append("<tr>");
            shtml.Append(" <td class=\"form_table_input_info\">点券购买额度：</td>");
            shtml.Append("<td>");
            shtml.Append("<input type=\"text\" id=\"txtIntegral\" name=\"txtIntegral\"  value=\"" + Integral + "\"/>");
            shtml.Append("</td>");
            shtml.Append("<td>");
            shtml.Append("<div class=\"msgNormal\" id=\"divIntegral\">请输入点券购买额度，最多能够使用的点券数量</div>");
            shtml.Append("</td>");
            shtml.Append(" </tr>");
            shtml.Append("<tr>");
            shtml.Append("<td class=\"form_table_input_info\">销售价格：</td>");
            shtml.Append("<td>");
            shtml.Append("<input type=\"hidden\" id=\"txtMemberPrice\" name=\"txtMemberPrice\"/>");
            shtml.Append("<input type=\"text\" id=\"txtShopPrice\" name=\"txtShopPrice\" value=\"" + Price + "\"/>&nbsp;<a href=\"javascript:showPath('SetMemberPrice',document.getElementById('SpecificationsAddress'),'设置会员价',650,250,'" + sp.DummyPaht + "','txtShopPrice;txtMemberPrice');\">设置会员价格</a>");
            shtml.Append(" </td>");
            shtml.Append("<td>");
            shtml.Append("<div class=\"msgNormal\" id=\"divShopPrice\">请输入销售价格</div>");
            shtml.Append(" </td>");
            shtml.Append("</tr>");
            shtml.Append("</table>");
            return shtml.ToString();
        }
        #endregion

        #region 删除相册图片
        private void DelAlbum(string Alubmid)
        {
            YXShop.BLL.Product.ProductAlbum pabll = new YXShop.BLL.Product.ProductAlbum();
            YXShop.Model.Product.ProductAlbum pamodel = pabll.GetModelID(Convert.ToInt32(Alubmid));
            if (pamodel != null)
            {
                ChangeHope.Common.FileHelper fh = new ChangeHope.Common.FileHelper();
                if (!string.IsNullOrEmpty(pamodel.OriginalAddress))
                {
                    fh.DeleteFile(Server.MapPath("~//" + pamodel.OriginalAddress));
                }
                if (!string.IsNullOrEmpty(pamodel.ThumbnailAddress))
                {
                    fh.DeleteFile(Server.MapPath("~//" + pamodel.ThumbnailAddress));
                }
                Response.Write(this.bindAlbum(pamodel.Productid));
            }
            pabll.Delete(Convert.ToInt32(Alubmid));
        }
        #endregion

        #region 搜索绑定相关商品
        private void SearchRelatedProduct(string Name)
        {
            YXShop.BLL.Product.ProductInfo bll = new YXShop.BLL.Product.ProductInfo();
            ChangeHope.DataBase.DataByPage dbp = bll.GetList(" [order by] pro_ID asc", 50, " and pro_Name like '%" + Name + "%'");
            StringBuilder select = new StringBuilder();
            select.Append("<select size=\"14\" id=\"selPro_RelatingProID\" style=\"width: 98%\">");
            if (dbp.DataReader != null)
            {
                select.Append("<option value=\"\"></option>");
                while (dbp.DataReader.Read())
                {
                    select.Append("<option value=\"" + dbp.DataReader["pro_ID"].ToString() + "\">" + dbp.DataReader["pro_Name"].ToString() + "</option>");
                }
            }
            select.Append("</select>");
            Response.Write(select.ToString());
        }
        #endregion

        #region 修改商品绑定相关商品
        protected void RelateProductBindInfo(string RelationProductID)
        {
            YXShop.BLL.Product.ProductInfo bll = new YXShop.BLL.Product.ProductInfo();
            ChangeHope.DataBase.DataByPage dbp = bll.GetList(" [order by] pro_ID asc", 50, " and pro_ID in (" + RelationProductID + ")");
            StringBuilder selectsb = new StringBuilder();
            selectsb.Append("<select name=\"selPro_RelatingProIDSelect\" size=\"14\" multiple=\"multiple\" style=\"width: 98%\">");
            if (dbp.DataReader != null)
            {
                while (dbp.DataReader.Read())
                {
                    
                    selectsb.Append("<option value=\"" + dbp.DataReader["pro_ID"].ToString() + "\" selected>" + dbp.DataReader["pro_Name"].ToString() + "</option>");
                }
            }
            selectsb.Append("</select>");
            this.ltRelatingProductSelected.Text = selectsb.ToString();
        }
        #endregion

        #region 搜索绑定相关文章
        private void SearchRelatedArticle(string Name)
        {
            YXShop.BLL.SystemInfo.Article bll = new YXShop.BLL.SystemInfo.Article();
            ChangeHope.DataBase.DataByPage dbp = bll.GetList(" and Title like '%" + Name + "%'");
            StringBuilder select = new StringBuilder();
            select.Append("<select size=\"14\" id=\"selPro_RelatingArtID\" multiple=\"multiple\" name=\"selPro_RelatingArtID\" style=\"width: 98%\">");
            if (dbp.DataReader != null)
            {
                select.Append("<option value=\"\"></option>");
                while (dbp.DataReader.Read())
                {
                    
                    select.Append("<option value=\"" + dbp.DataReader["Id"].ToString() + "\">" + dbp.DataReader["Title"].ToString() + "</option>");
                }
            }
            select.Append("</select>");
            Response.Write(select.ToString());
        }
        #endregion

        #region 修改商品绑定相关文章
        protected void RelateArticleBindInfo(string RelationArticleID)
        {
            YXShop.BLL.SystemInfo.Article bll = new YXShop.BLL.SystemInfo.Article();
            ChangeHope.DataBase.DataByPage dbp = bll.GetList(" and Id in (" + RelationArticleID + ")");
            StringBuilder selectsb = new StringBuilder();
            selectsb.Append("<select name=\"selPro_RelatingArtIDSelect\" size=\"14\" multiple=\"multiple\" style=\"width: 98%\">");
            if (dbp.DataReader != null)
            {
                while (dbp.DataReader.Read())
                {
                    selectsb.Append("<option value=\"" + dbp.DataReader["Id"].ToString() + "\" selected>" + dbp.DataReader["Title"].ToString() + "</option>");
                }
            }
            selectsb.Append("</select>");
            this.ltRelatingArticle.Text = selectsb.ToString();
        }
        #endregion

        #region 绑定商品信息
        protected void BindInfo(int ProductId)
        {
            YXShop.BLL.Product.ProductInfo bll = new YXShop.BLL.Product.ProductInfo();
            YXShop.Model.Product.ProductInfo model = bll.GetModel(ProductId);
            this.hfcid.Value = model.pro_CID.ToString();
            this.txtProductClass.Text = model.ProClassName;
            this.bindProductType(model.pro_Type);
            this.txtProductName.Text = model.pro_Name;
            this.txtItemNo.Text = model.pro_NO;
            this.litProductBrand.Text = this.BrandList(model.pro_Type,model.pro_BrandID.ToString());
            this.bindUnit(model.pro_Unit);//单位
            this.txtWeiht.Text = model.pro_Weight.ToString();
            this.rblIsShelves.SelectedValue = model.pro_Audit.ToString();
            this.txtFilingTime.Text = model.pro_AutoUp.ToString();
            this.txtDownTime.Text = model.pro_AutoDown.ToString();
            this.txtUpCount.Text = model.pro_AuditCount.ToString();
            this.txtDonateInteg.Text = model.pro_DonateIntegral.ToString();
            this.txtMarketPrice.Text = Convert.ToDouble(model.pro_MarketPrice).ToString("f2");
            this.txtCostPrice.Text = Convert.ToDouble(model.pro_CostPrice).ToString("f2");
            this.txtAlarm.Text = model.pro_Alarm.ToString();
            this.txtContentPageTemplate.Text = model.pro_ContentTemplate;
            if (!string.IsNullOrEmpty(model.pro_Specialspecifications))
            {
                Regex ssSpace = new Regex(@"s_spacebar");
                string[] ssv = ssSpace.Split(model.pro_Specialspecifications);
                this.IsSpecAlbum.Value = "1";
                this.SpecialSpecValue.Value = ssv[1];
                this.SpecialSpecName.Value = ssv[0];
            }
            #region 商品状态：推荐商品|热卖商品|特价商品|活动专区|最新商品|首页显示
            string[] state = model.pro_State.Split('|');
            for (int i = 0; i < state.Length; i++)
            {
                if (state[i] == "1")
                {
                    this.chklstState.Items[i].Selected = true;
                }
            }
            #endregion
            #region 商品标识：团购|拍卖|批发
            string[] Designation = model.pro_Designation.Split('|');
            for (int j = 0; j < Designation.Length; j++)
            {
                if (Designation[j] == "1")
                {
                    this.chklstMarking.Items[j].Selected = true;
                }
            }
            #endregion
            YXShop.BLL.Product.ProductSpecification speBll = new YXShop.BLL.Product.ProductSpecification();
            List<YXShop.Model.Product.ProductSpecification> speList = speBll.GetSpecification(ProductId);
            if (speList.Count > 0)
            {
                if (model.pro_Specifications != "")
                {
                    this.litSpecifications.Text = this.SpecificationsProduct(speList, model.pro_Specifications);
                }
                else
                {
                    this.litSpecifications.Text = this.Specifications(model.pro_Stock.ToString(), model.pro_IntegralPrice.ToString(), Convert.ToDouble(model.pro_ShopPrice).ToString("f2"));
                }
            }
            else
            {
                this.litSpecifications.Text = this.Specifications(model.pro_Stock.ToString(), model.pro_IntegralPrice.ToString(), Convert.ToDouble(model.pro_ShopPrice).ToString("f2"));
            }
            this.litSparepartContents.Text = this.BindSparepart(ProductId);
            this.txtDescription.Text = model.pro_Synopsis;
            this.txtContent.Value = model.pro_Content;
            this.litaAlbum.Text=this.bindAlbum(ProductId);
            this.litPropery.Text = this.ProductProperty(model.pro_Type, model.pro_Property);
            if (model.pro_Property.Trim() != "" && model.pro_Property.Trim() != string.Empty)
            {
                this.TabTitle4.Style.Value = "display:";
            }
            this.litParameter.Text = this.ProductParameter(model.pro_Type, model.pro_Parameters);
            if (model.pro_Parameters != "" && model.pro_Parameters != string.Empty)
            {
                this.TabTitle5.Style.Value = "display:";
            }
            this.RelateProductBindInfo(model.pro_RelatingproID);
            this.RelateArticleBindInfo(model.pro_RelatingArtID);
            this.txtOptimizationtitle.Text = model.pro_MetaTitle;
            this.txtOptimizationKey.Text = model.pro_MetaKeywords;
            this.txtOptimizationDescription.Text = model.pro_MetaDescription;
            this.hfItemNo.Value = model.pro_NO;
            ViewState["PutoutID"] = model.pro_PutoutID;
            ViewState["PutoutTypeID"] = model.pro_PutoutType;
            ViewState["ID"] = model.pro_ID;
            ViewState["pro_Thumbnail"] = model.pro_Thumbnail;
            ViewState["pro_Original"] = model.pro_Original;
            ViewState["pro_Images"] = model.pro_Images;
        }
        #region 绑定规格信息
        //绑定规格信息
        private string SpecificationsProduct(List<YXShop.Model.Product.ProductSpecification> list, string NameAndValue)
        {
            YXShop.Common.SysParameter sp = new YXShop.Common.SysParameter();
            StringBuilder shtml = new StringBuilder();
            Regex nameSpace = new Regex(@"g_space");
            Regex valueSpace = new Regex(@"n_v_space");
            string[] strNameAndValue = nameSpace.Split(NameAndValue);
            shtml.Append("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
            shtml.Append("<tr height=\"24px\" bgcolor=\"#FFFFFF\">");
            shtml.Append("<td style=\"font-weight:bold;font-size:14px;\">&nbsp;&nbsp;规格");
            shtml.Append("<input type=\"hidden\" name=\"SpeGroupCount\" id=\"SpeGroupCount\" value=\"" + strNameAndValue.Length+ "\" />");
            shtml.Append("<input type=\"hidden\" name=\"SpecificationRows\" id=\"SpecificationRows\" value=\"" + list.Count + "\" />");
            shtml.Append("</td>");
            shtml.Append("</tr>");
            shtml.Append("<tr bgcolor=\"#EBEDE8\" height=\"22px\">");
            shtml.Append("<td>&nbsp;&nbsp;<a href=\"javascript:showPath('AddSpecifications',document.getElementById('SpecificationsAddress'),'开启规格',650,250,'" + sp.DummyPaht + "');\">添加规格</a>  <a href='javascript:CloseSpecifications();'>关闭规格</a></td>");
            shtml.Append("</tr>");
            shtml.Append("<tr>");
            shtml.Append("<td bgcolor=\"#BAC9C6\" height='2px'>");
            shtml.Append("</td>");
            shtml.Append("</tr>");
            shtml.Append("<tr>");
            shtml.Append("<td>");
            shtml.Append("<span id=\"SpecificationsContent\">");
            shtml.Append("<table id=\"SpecificationTable\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");
            shtml.Append("<tr bgcolor=\"#F5F5F5\" height=\"22px\">");
            shtml.Append("<td style=\"font-weight:bold; text-align:center; width:156px\">货号</td>");
            shtml.Append("<span id=\"SpeTitle\">");
            int g = 1;
            foreach (string name in strNameAndValue)
            {
                string[] strName = valueSpace.Split(name);
                if (strName[0].ToString() != "" && strName[1].ToString() != "")
                {
                    shtml.Append("<td style=\"font-weight:bold; text-align:center;\" >");
                    shtml.Append("<input type=\"hidden\" name=\"SpecificationsName" + g + "\" id=\"SpecificationsName" + g + "\" value=\"" + strName[0] + "\" />");
                    shtml.Append("<input type=\"hidden\" name=\"SpecificationsValue" + g + "\" id=\"SpecificationsValue" + g + "\" value=\"" + strName[1] + "\" />");
                    shtml.Append("" + strName[0] + "");
                    shtml.Append("</td>");
                    g++;
                }

            }
            shtml.Append("</span>");
            shtml.Append("<td style=\"font-weight:bold;\">库存</td>");
            shtml.Append("<td style=\"font-weight:bold;\">积分</td>");
            shtml.Append("<td style=\"font-weight:bold;\">价格</td>");
            shtml.Append("<td>操作</td>");
            shtml.Append("</tr>");
            for (int i = 0; i < list.Count; i++)
            {
                shtml.Append("<tr id=\"trSpeRows" + i + "\">");
                shtml.Append("<td>");
                shtml.Append("<input type=\"hidden\" name=\"SpeValRows" + i + "\" id=\"SpeValRows" + i + "\" value=\"" + i + "\"/>");
                shtml.Append("<span id=\"spanSpeValue" + i + "\"><input type=\"hidden\" name=\"SpeValue" + i + "\" id=\"SpeValue" + i + "\" value=\"" + list[i].Specifications + "\"/></span>");
                shtml.Append("<input type=\"text\" name=\"SpeItemNo" + i + "\" value='"+list[i].ProductCode+"' id=\"SpeItemNo" + i + "\" />");
                shtml.Append("</td>");
                shtml.Append("<span id=\"SpeValueGroup" + i + "\">");
                string[] specificationsValue = list[i].Specifications.Split(',');
                foreach (string va in specificationsValue)
                {
                    if (va != "")
                    {
                        shtml.Append("<td style=\"text-align:center;\">" + va.Replace("\r", "") + "</td>");
                    }
                }
                shtml.Append("</span>");
                shtml.Append("<td><input type=\"text\" class=\"short_input\" name=\"SpeStock" + i + "\" value='"+list[i].ProductStock+"' id=\"SpeStock" + i + "\" /></td>");
                shtml.Append("<td><input type=\"text\" class=\"short_input\" name=\"SpeIntegral" + i + "\" value='" + list[i].IntegralToBuy + "' id=\"SpeIntegral" + i + "\" /></td>");
                shtml.Append("<td>");
                shtml.Append("<input type=\"text\" class=\"short_input\" name=\"SpeShopPrice" + i + "\" value='" + list[i].SalePrice + "' id=\"SpeShopPrice" + i + "\" />");
                shtml.Append("<input type=\"hidden\" class=\"short_input\" name=\"SpeMemberPrice" + i + "\" value='" + list[i].MemberPrice + "' id=\"SpeMemberPrice" + i + "\" />");
                shtml.Append("</td>");
                shtml.Append("<td><a href=\"javascript:showPath('SetMemberPrice',document.getElementById('SpecificationsAddress'),'设置会员价',650,250,'" + sp.DummyPaht + "','SpeShopPrice" + i + ";SpeMemberPrice" + i + "');\">会员价</a> <a href='javascript:DelSpecificationRow(" + i + ")'>删除</a></td>");
                shtml.Append("</tr>");
            }
            shtml.Append("</table>");
            shtml.Append("</span>");
            shtml.Append("</td>");
            shtml.Append("</tr>");
            shtml.Append("</table>");
            this.isStartspecification.Value = "1";
            return shtml.ToString();
        }
#endregion

        #region 绑定配件
        /// <summary>
        /// 绑定配件
        /// </summary>
        private string BindSparepart(int ProductId)
        {
            YXShop.BLL.Product.ProductSparepart bll=new YXShop.BLL.Product.ProductSparepart();
            List<YXShop.Model.Product.ProductSparepart> list=bll.GetSparepart(ProductId);

            YXShop.Common.SysParameter sp = new YXShop.Common.SysParameter();
            StringBuilder shtml = new StringBuilder();
            if (list.Count > 0)
            {
                this.hfSparepartGroup.Value = list.Count.ToString();
                for (int i = 0; i < list.Count; i++)
                {
                    int sparepartCount = i;
                    shtml.Append("<div id='SparepartGroupCount" + sparepartCount + "'>");
                    shtml.Append("<table class=\"form_table_input\" style='border-top:solid 2px #BAC9C6;' border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">");
                    shtml.Append("<tr>");
                    shtml.Append("<td class=\"form_table_input_info\">配件组名称：</td>");
                    shtml.Append("<td>");
                    shtml.Append("<input type=\"hidden\" name=\"hfSparepartId\" id=\"hfSparepartId\" value=\"" + sparepartCount + "\"/>");
                    shtml.Append("<input id=\"txtSparepartName" + sparepartCount + "\" value=\"" + list[i].SparepartName + "\" name=\"txtSparepartName" + sparepartCount + "\" />");
                    shtml.Append("</td>");
                    shtml.Append("<td class=\"page_button\">");
                    shtml.Append("<a ID=\"HyperLink5\" Class=\"inputbutton\" href=\"javascript:DelSparepartGroup(" + sparepartCount + ")\" Width=\"65px\" Height=\"24px\" onMouseOver=\"javascript:document.getElementById(this.id).className='inputbutton_a'\" onMouseOut=\"javascript:document.getElementById(this.id).className='inputbutton'\">删除此配件</a>");
                    shtml.Append("</td>");
                    shtml.Append("</tr>");
                    shtml.Append("<tr>");
                    shtml.Append("<td class=\"form_table_input_info\">最小购买量：</td>");
                    shtml.Append("<td>");
                    shtml.Append("<input id=\"txtMinCount" + sparepartCount + "\" name=\"txtMinCount" + sparepartCount + "\" value=\"" + list[i].BuyMinCount + "\" class=\"short_input\" />");
                    shtml.Append(" </td>");
                    shtml.Append(" <td>");
                    shtml.Append(" <div class=\"msgNormal\">请输入最小购买量</div>");
                    shtml.Append(" </td>");
                    shtml.Append("</tr>");
                    shtml.Append("<tr>");
                    shtml.Append("<td class=\"form_table_input_info\">最大购买量：</td>");
                    shtml.Append("<td>");
                    shtml.Append("<input id=\"txtMaxCount" + sparepartCount + "\" value=\"" + list[i].BuyMaxCount + "\" name=\"txtMaxCount" + sparepartCount + "\" class=\"short_input\" />");
                    shtml.Append("</td>");
                    shtml.Append("<td>");
                    shtml.Append(" <div class=\"msgNormal\">请输入最大购买量</div>");
                    shtml.Append("</td>");
                    shtml.Append("</tr>");
                    shtml.Append("<tr>");
                    shtml.Append("<td class=\"form_table_input_info\">配件优惠：</td>");
                    shtml.Append("<td>");
                    if (list[i].FavourableType == 0)
                    {
                        shtml.Append("<input name=\"SparepartFavourable" + sparepartCount + "\" type=\"radio\" value='0' checked=\"checked\"/>优惠某个折扣");
                        shtml.Append("<input name=\"SparepartFavourable" + sparepartCount + "\" type=\"radio\" value='1' />优惠一定金额");
                    }
                    else
                    {
                        shtml.Append("<input name=\"SparepartFavourable" + sparepartCount + "\" type=\"radio\" value='0'/>优惠某个折扣");
                        shtml.Append("<input name=\"SparepartFavourable" + sparepartCount + "\" type=\"radio\" value='1' checked=\"checked\"/>优惠一定金额");
                    }
                    shtml.Append("</td>");
                    shtml.Append("<td>");
                    shtml.Append("<div class=\"msgNormal\">请选择配件优惠类型。</div>");
                    shtml.Append("</td>");
                    shtml.Append(" </tr>");
                    shtml.Append("<tr>");
                    shtml.Append("<td class=\"form_table_input_info\">优惠额度：</td>");
                    shtml.Append("<td>");
                    shtml.Append("<input id=\"txtFavourablePrice" + sparepartCount + "\" value=\"" + Convert.ToDouble(list[i].FavourableLimit).ToString("f2") + "\" name=\"txtFavourablePrice" + sparepartCount + "\" class=\"short_input\" />");
                    shtml.Append("</td>");
                    shtml.Append("<td>");
                    shtml.Append(" <div class=\"msgNormal\">(无优惠可不填；优惠9折就输入0.9，优惠100元就输入100)</div>");
                    shtml.Append("</td>");
                    shtml.Append(" </tr>");
                    shtml.Append("<tr>");
                    shtml.Append("<td class=\"form_table_input_info\">添加配件商品：</td>");
                    shtml.Append("<td colspan=\"3\">");
                    shtml.Append("<table width=\"100%\" style=\" background-color:#F5F5F5\" cellpadding=\"1\" cellspacing=\"1\">");
                    shtml.Append("<tr style=\"background-color:#EBEDE8; height:22px;font-weight:bold;\">");
                    shtml.Append("<td width=\"10%\">");
                    shtml.Append("<a href=\"javascript:showPath('ProductSparepart',document.getElementById('address'),'选择配件',640,350,'" + sp.DummyPaht + "'," + sparepartCount + ");\">添加商品</a>");
                    shtml.Append("</td>");
                    shtml.Append("<td width=\"40%\">商品名称</td>");
                    shtml.Append("<td width=\"50%\">物品描述</td>");
                    shtml.Append("</tr>");
                    shtml.Append("</table>");
                    shtml.Append("<div id='SparepartProduct" + sparepartCount + "'>");
                    if (list[i].SparepartProduct != "")
                    {
                        YXShop.BLL.Product.ProductInfo productBll = new YXShop.BLL.Product.ProductInfo();
                        DataTable dt = productBll.DTGetListWhere(" and pro_ID in (" + list[i].SparepartProduct + ")");
                        shtml.Append("<table widht='100%'>");
                        if (dt.Rows.Count > 0)
                        {
                            for (int p = 0; p < dt.Rows.Count; p++)
                            {
                                shtml.Append("<tr style='height:22px'>");
                                shtml.Append("<td><a href=\"javascript:delSparepartProductId(" + dt.Rows[p]["pro_ID"].ToString() + "," + sparepartCount + ")\">删除</a></td>");
                                shtml.Append("<td width=\"40%\"><span title='" + dt.Rows[p]["pro_Name"].ToString() + "'>" + ChangeHope.Common.StringHelper.SubString(dt.Rows[p]["pro_Name"].ToString(), 20) + "</span></td>");
                                shtml.Append("<td width=\"50%\"><span title=\"" + dt.Rows[p]["pro_Synopsis"].ToString() + "\">" + ChangeHope.Common.StringHelper.SubString(dt.Rows[p]["pro_Synopsis"].ToString(), 30) + "</span></td>");
                                shtml.Append("</tr>");
                            }
                        }
                        shtml.Append("</table>");
                    }
                    shtml.Append("</div>");
                    shtml.Append("</td>");
                    shtml.Append("</tr>");
                    shtml.Append("<tr><td colspan='3'><input type=\"hidden\" name=\"hfProductSparepartID" + sparepartCount + "\" id=\"hfProductSparepartID" + sparepartCount + "\" value=\"" + list[i].SparepartProduct + "\" /></td></tr>");
                    shtml.Append("</table>");
                    shtml.Append("</div>");
                }
            }
            return shtml.ToString();
        }
        #endregion

        #region 绑定商品相册
        protected string bindAlbum(int productid)
        {
            YXShop.Common.SysParameter sp = new YXShop.Common.SysParameter();
            YXShop.BLL.Product.ProductAlbum pabll = new YXShop.BLL.Product.ProductAlbum();
            DataTable dt = pabll.GetProAlbumAll(productid,-1,0);
            StringBuilder str = new StringBuilder();
            int j = 1;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                str.Append("<td align='center'><img width=\"100px\" height=\"100px\" src=\"" + sp.DummyPaht + dt.Rows[i]["originaladdress"].ToString() + "\"/><br/><br/><span onclick=\"DelProAlbum(" + dt.Rows[i]["id"].ToString() + ");\"  style=\"cursor:hand;width:45px\" >删除</span></td>");
                if (j % 6 == 0)
                {
                    str.Append("</tr><tr>");
                }
                j++;
            }

          return str.ToString();
        }
        #endregion

        #endregion

        #region 修改与添加
        protected void butSave_Click(object sender, EventArgs e)
        {
            int putoutType = ChangeHope.WebPage.PageRequest.GetQueryInt("putoutType");
            YXShop.BLL.Product.ProductInfo bll = new YXShop.BLL.Product.ProductInfo();
            YXShop.Model.Product.ProductInfo model = new YXShop.Model.Product.ProductInfo();
            string itemNo = this.txtItemNo.Text.Trim() == "" ? this.GoodsNO() : this.txtItemNo.Text.Trim();
            DataTable dt = bll.DTGetListWhere(" and pro_NO='" + itemNo + "'");
            model.pro_CID = this.hfcid.Value != "" ? this.hfcid.Value : "0";
            model.pro_Type = ChangeHope.WebPage.PageRequest.GetFormString("selProductType") != "" ? Convert.ToInt32(ChangeHope.WebPage.PageRequest.GetFormString("selProductType")) : 0;
            model.pro_Property = this.PropertyValue();
            model.pro_Area = this.hfid.Value;
            model.pro_Parameters = this.ParameterValue();
            model.pro_Name = this.txtProductName.Text;
            model.pro_NO = itemNo;
            model.pro_BrandID =Convert.ToInt32(ChangeHope.WebPage.PageRequest.GetFormString("selBrand"));
            model.pro_Unit = ChangeHope.WebPage.PageRequest.GetFormString("selUnit") == "0" ? "" : ChangeHope.WebPage.PageRequest.GetFormString("selUnit");
            model.pro_Weight = this.txtWeiht.Text.Trim() != "" ? Convert.ToDecimal(this.txtWeiht.Text.Trim()) : 0;
            model.pro_Audit=Convert.ToInt32(this.rblIsShelves.SelectedValue);
            model.pro_AutoUp = this.txtFilingTime.Text.Trim() != "" ? Convert.ToDateTime(this.txtFilingTime.Text.Trim()) : System.DateTime.Now;
            model.pro_AutoDown = this.txtDownTime.Text.Trim() != "" ? Convert.ToDateTime(this.txtDownTime.Text.Trim()) : Convert.ToDateTime("2020-01-01");
            model.pro_AuditCount = this.txtUpCount.Text.Trim() != "" ? Convert.ToInt32(this.txtUpCount.Text.Trim()) : 0;
            model.pro_DonateIntegral = this.txtDonateInteg.Text.Trim() != "" ? Convert.ToDecimal(this.txtDonateInteg.Text.Trim()) : 0;
            model.pro_MarketPrice = this.txtMarketPrice.Text.Trim() != "" ? Convert.ToDecimal(this.txtMarketPrice.Text.Trim()) : 0;
            model.pro_CostPrice = this.txtCostPrice.Text.Trim() != "" ? Convert.ToDecimal(this.txtCostPrice.Text.Trim()) : 0;
            model.pro_ContentTemplate = this.txtContentPageTemplate.Text.Trim();
            model.pro_Alarm = this.txtAlarm.Text != "" ? Convert.ToInt32(this.txtAlarm.Text) : 0;
            model.pro_PutoutID = ViewState["PutoutID"]==null?0:Convert.ToInt32(ViewState["PutoutID"].ToString());
            if (putoutType >= 0)
            {
                model.pro_PutoutType = putoutType;
            }
            else
            {
                model.pro_PutoutType = ViewState["PutoutTypeID"] == null ? 0 : Convert.ToInt32(ViewState["PutoutTypeID"].ToString());
            }
            #region 商品状态：推荐商品|热卖商品|特价商品|活动专区|最新商品|首页显示
            string Pro_State = "";
            for (int i = 0; i < this.chklstState.Items.Count; i++)
            {
                if (chklstState.Items[i].Selected)
                {
                    Pro_State += "1|";
                }
                else
                {
                    Pro_State += "0|";
                }
            }
            #endregion
            model.pro_State = Pro_State;
            #region 商品标识：团购|拍卖|批发
            string Pro_Designation = "";
            for (int j = 0; j < this.chklstMarking.Items.Count; j++)
            {
                if (chklstMarking.Items[j].Selected)
                {
                    Pro_Designation += "1|";
                }
                else
                {
                    Pro_Designation += "0|";
                }
            }
            #endregion
            model.pro_Designation = Pro_Designation;
            string speType =this.isStartspecification.Value.Trim();
            if (speType == "0")
            {
                model.pro_Stock = ChangeHope.WebPage.PageRequest.GetFormInt("txtStock") > 0 ? ChangeHope.WebPage.PageRequest.GetFormInt("txtStock") : 0;
                model.pro_IntegralPrice = ChangeHope.WebPage.PageRequest.GetFormString("txtIntegral") != "" ? Convert.ToDecimal(ChangeHope.WebPage.PageRequest.GetFormString("txtIntegral")) : 0;
                model.pro_ShopPrice = ChangeHope.WebPage.PageRequest.GetFormString("txtShopPrice") != "" ? Convert.ToDecimal(ChangeHope.WebPage.PageRequest.GetFormString("txtShopPrice")) : 0;
                model.pro_RatingDiscount = ChangeHope.WebPage.PageRequest.GetFormString("txtMemberPrice");
            }
            else
            {
                model.pro_Stock = 0;
                model.pro_IntegralPrice = 0;
                model.pro_ShopPrice =  0;
                model.pro_RatingDiscount = "";
            }
            //图片参数
            YXShop.Common.SysParameter sys = new YXShop.Common.SysParameter();
            bool WhetherWater = sys.IsWatermark;
            string OriginalThumbnailSavePath = "/yxuploadfile/product/originalthumbnail";
            string OriginalSavePath = "/yxuploadfile/product/original";
            string ThumbnailSavePath = "/yxuploadfile/product/thumbnail";
            int ThumbnailsHeight = sys.ThumbnailsHeight;
            int ThumbnailsWidth = sys.ThumbnailsWidth;
            int ImagesThumbnailsHeight = sys.ImagesThumbnailsHeight;
            int ImagesThumbnailsWidth = sys.ImagesThumbnailsWidth;
            int TextWatermarkTransparent = sys.TextWatermarkTransparent;
            int ImageWatermarkTransparent = sys.ImageWatermarkTransparent;
            string TextOrImagesWatermark = sys.TextOrImagesWatermark;
            string WatermarkText = sys.WatermarkText;
            string WatermarkImage = sys.WatermarkImage;
            string WatermarkPosition = sys.WatermarkPosition;
            string Original = string.Empty;
            string OriginalThumbnails = string.Empty;
            string ThumbnailsImage = string.Empty;
            ChangeHope.Common.UploadProcesedImages wm = new ChangeHope.Common.UploadProcesedImages();
            YXShop.Common.SysParameter sp=new YXShop.Common.SysParameter();
            #region 上传图品详细图
            if (fuPic.HasFile)
            {
                //原图
                ChangeHope.Common.UploadFile uf = new ChangeHope.Common.UploadFile();
                uf.ExtensionLim = ".gif,.jpg,.jpeg,.bmp";
                uf.FileLengthLim =sp.ImageSize;
                uf.PostedFile = this.fuPic;
                uf.SavePath = OriginalSavePath;
                if (uf.Upload())
                {
                    if (uf.HaveLoad)
                    {
                        Original = uf.FilePath;
                        //原图缩略图
                        wm.SourceImagePath = Original;
                        wm.ThumbnailImagePath = OriginalThumbnailSavePath;
                        wm.ThumbnailImageWidth = ImagesThumbnailsWidth;
                        wm.ThumbnailImageHeight = ImagesThumbnailsHeight;
                        if (wm.ToThumbnailImage())
                        {
                            OriginalThumbnails = wm.FilePath;
                        }
                        else
                        {
                            this.ltlMsg.Text = "操作失败，" + wm.Message + "";
                            this.pnlMsg.Visible = true;
                            this.pnlMsg.CssClass = "actionOk";
                            return;
                        }

                    }
                }
                else
                {
                    this.ltlMsg.Text = "操作失败，" + uf.Message + "";
                    this.pnlMsg.Visible = true;
                    this.pnlMsg.CssClass = "actionOk";
                    return;
                }
                if (WhetherWater)
                {
                    //原图水印
                    if (!string.IsNullOrEmpty(Original))
                    {
                        wm.SourceImagePath = Original;
                        wm.ImageDeaphaneity = float.Parse(ImageWatermarkTransparent.ToString());
                        wm.Diaphaneity = TextWatermarkTransparent;
                        switch (WatermarkPosition)
                        {
                            case "1":
                                wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.LeftTop;
                                break;
                            case "2":
                                wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.LeftBottom;
                                break;
                            case "3":
                                wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.RightTop;
                                break;
                            case "4":
                                wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.RightBottom;
                                break;
                            case "5":
                                wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.CenterTop;
                                break;
                            case "9":
                                wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.Center;
                                break;
                            case "7":
                                wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.CenterBottom;
                                break;
                        }
                        if (TextOrImagesWatermark == "0")
                        {
                            //图片水印
                            if (!string.IsNullOrEmpty(WatermarkImage))
                            {
                                wm.WaterMarkImagePath = WatermarkImage;
                            }
                            else
                            {
                                this.ltlMsg.Text = "操作失败，上传图片水印失败，请确认系统设置水印图片是否存在。";
                                this.pnlMsg.Visible = true;
                                this.pnlMsg.CssClass = "actionOk";
                                return;
                            }
                        }
                        else
                        {
                            //文字水印
                            if (!string.IsNullOrEmpty(WatermarkText))
                            {
                                wm.WaterMarkText = WatermarkText;
                            }
                            else
                            {
                                this.ltlMsg.Text = "操作失败，上传图片水印失败，请确认系统设置水印文字是否存在。";
                                this.pnlMsg.Visible = true;
                                this.pnlMsg.CssClass = "actionOk";
                                return;
                            }
                        }
                        wm.SaveWaterMarkImagePath = OriginalSavePath;
                        if (wm.ToWaterMark())
                        {
                            Original = wm.FilePath;
                        }
                        else
                        {
                            this.ltlMsg.Text = "操作失败，" + wm.Message + "";
                            this.pnlMsg.Visible = true;
                            this.pnlMsg.CssClass = "actionOk";
                            return;
                        }
                    }
                    //原图缩略图水印
                    if (!string.IsNullOrEmpty(OriginalThumbnails))
                    {
                        wm.SourceImagePath = OriginalThumbnails;
                        wm.ImageDeaphaneity = float.Parse(ImageWatermarkTransparent.ToString());
                        wm.Diaphaneity = TextWatermarkTransparent;
                        switch (WatermarkPosition)
                        {
                            case "1":
                                wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.LeftTop;
                                break;
                            case "2":
                                wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.LeftBottom;
                                break;
                            case "3":
                                wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.RightTop;
                                break;
                            case "4":
                                wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.RightBottom;
                                break;
                            case "5":
                                wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.CenterTop;
                                break;
                            case "9":
                                wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.Center;
                                break;
                            case "7":
                                wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.CenterBottom;
                                break;
                        }
                        if (TextOrImagesWatermark == "0")
                        {
                            //图片水印
                            if (!string.IsNullOrEmpty(WatermarkImage))
                            {
                                wm.WaterMarkImagePath = WatermarkImage;
                            }
                            else
                            {
                                this.ltlMsg.Text = "操作失败，上传图片水印失败，请确认系统设置水印图片是否存在。";
                                this.pnlMsg.Visible = true;
                                this.pnlMsg.CssClass = "actionOk";
                                return;
                            }
                        }
                        else
                        {
                            //文字水印
                            if (!string.IsNullOrEmpty(WatermarkText))
                            {
                                wm.WaterMarkText = WatermarkText;
                            }
                            else
                            {
                                this.ltlMsg.Text = "操作失败，上传图片水印失败，请确认系统设置水印文字是否存在。";
                                this.pnlMsg.Visible = true;
                                this.pnlMsg.CssClass = "actionOk";
                                return;
                            }
                        }
                        wm.SaveWaterMarkImagePath = OriginalThumbnailSavePath;
                        if (wm.ToWaterMark())
                        {
                            OriginalThumbnails = wm.FilePath;
                        }
                        else
                        {
                            this.ltlMsg.Text = "操作失败，" + wm.Message + "";
                            this.pnlMsg.Visible = true;
                            this.pnlMsg.CssClass = "actionOk";
                            return;
                        }
                    }

                }
                //自动生成商品缩略图
                if (this.cbBreviary.Checked)
                {
                    wm.SourceImagePath = Original;
                    wm.ThumbnailImagePath = ThumbnailSavePath;
                    wm.ThumbnailImageWidth = Convert.ToInt32(ThumbnailsWidth);
                    wm.ThumbnailImageHeight = Convert.ToInt32(ThumbnailsHeight);
                    if (wm.ToThumbnailImage())
                    {
                        ThumbnailsImage = wm.FilePath;
                    }
                    else
                    {
                        this.ltlMsg.Text = "操作失败，" + wm.Message + "";
                        this.pnlMsg.Visible = true;
                        this.pnlMsg.CssClass = "actionOk";
                        return;
                    }
                }
            }
            else
            {
                if (ViewState["ID"] != null)
                {
                    if (ViewState["pro_Thumbnail"] != null)
                    {
                        ThumbnailsImage = ViewState["pro_Thumbnail"].ToString();
                    }
                    if (ViewState["pro_Original"] != null)
                    {
                        Original = ViewState["pro_Original"].ToString();
                    }
                    if (ViewState["pro_Images"] != null)
                    {
                        OriginalThumbnails = ViewState["pro_Images"].ToString();
                    }
                }
            }
            #endregion

            #region 上传缩略图
            if (fuSmallImages.HasFile && !cbBreviary.Checked)
            {
                ChangeHope.Common.UploadFile uf = new ChangeHope.Common.UploadFile();
                uf.ExtensionLim = ".gif,.jpg,.jpeg,.bmp";
                uf.FileLengthLim = sp.ImageSize;
                uf.PostedFile = this.fuSmallImages;
                uf.SavePath = ThumbnailSavePath;
                if (uf.Upload())
                {
                    if (uf.HaveLoad)
                    {
                        ThumbnailsImage = uf.FilePath;
                    }
                }
                else
                {
                    this.ltlMsg.Text = "操作失败，" + uf.Message + "";
                    this.pnlMsg.Visible = true;
                    this.pnlMsg.CssClass = "actionOk";
                    return;
                }
                if (WhetherWater)
                {
                    if (!string.IsNullOrEmpty(ThumbnailsImage))
                    {
                        wm.SourceImagePath = ThumbnailsImage;
                        wm.ImageDeaphaneity = ImageWatermarkTransparent;
                        wm.Diaphaneity = TextWatermarkTransparent;
                        switch (WatermarkPosition)
                        {
                            case "1":
                                wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.LeftTop;
                                break;
                            case "2":
                                wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.LeftBottom;
                                break;
                            case "3":
                                wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.RightTop;
                                break;
                            case "4":
                                wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.RightBottom;
                                break;
                            case "5":
                                wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.CenterTop;
                                break;
                            case "9":
                                wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.Center;
                                break;
                            case "7":
                                wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.CenterBottom;
                                break;
                        }
                        if (TextOrImagesWatermark == "0")
                        {
                            //图片水印
                            if (!string.IsNullOrEmpty(WatermarkImage))
                            {
                                wm.WaterMarkImagePath = WatermarkImage;
                            }
                            else
                            {
                                this.ltlMsg.Text = "操作失败，上传图片水印失败，请确认系统设置水印图片是否存在。";
                                this.pnlMsg.Visible = true;
                                this.pnlMsg.CssClass = "actionOk";
                                return;
                            }
                        }
                        else
                        {
                            //文字水印
                            if (!string.IsNullOrEmpty(WatermarkText))
                            {
                                wm.WaterMarkText = WatermarkText;
                            }
                            else
                            {
                                this.ltlMsg.Text = "操作失败，上传图片水印失败，请确认系统设置水印文字是否存在。";
                                this.pnlMsg.Visible = true;
                                this.pnlMsg.CssClass = "actionOk";
                                return;
                            }
                        }
                        wm.SaveWaterMarkImagePath = ThumbnailSavePath;
                        if (wm.ToWaterMark())
                        {
                            ThumbnailsImage = wm.FilePath;
                        }
                        else
                        {
                            this.ltlMsg.Text = "操作失败，" + wm.Message + "";
                            this.pnlMsg.Visible = true;
                            this.pnlMsg.CssClass = "actionOk";
                            return;
                        }
                    }
                }
            }
            else
            {
                if (ViewState["ID"] != null)
                {
                    if (ViewState["pro_Thumbnail"] != null && ViewState["pro_Thumbnail"].ToString() != string.Empty)
                    {
                        ThumbnailsImage = ViewState["pro_Thumbnail"].ToString();
                    }
                }
            }
            #endregion

            model.pro_Original = Original;
            model.pro_Images = OriginalThumbnails;
            model.pro_Thumbnail = ThumbnailsImage;
            model.pro_Synopsis = this.txtDescription.Text;
            model.pro_Content = this.txtContent.Value;
            model.pro_RelatingArtID = ChangeHope.WebPage.PageRequest.GetFormString("selPro_RelatingArtIDSelect");
            model.pro_RelatingproID = ChangeHope.WebPage.PageRequest.GetFormString("selPro_RelatingProIDSelect");
            model.pro_MetaKeywords = this.txtOptimizationKey.Text;
            model.pro_MetaDescription = this.txtOptimizationDescription.Text;
            model.pro_MetaTitle = this.txtOptimizationtitle.Text;
            model.pro_UpdateTime = System.DateTime.Now;
            if (this.IsSpecAlbum.Value == "1")
            {
                model.pro_Specialspecifications = this.SpecialSpecName.Value + "s_spacebar" + this.SpecialSpecValue.Value;
            }
            #region 获取规格值
            if (Convert.ToInt32(this.isStartspecification.Value) == 1)
            {
                string specificationsData = string.Empty;
                int speGroupCount = ChangeHope.WebPage.PageRequest.GetFormInt("SpeGroupCount");
                for (int s = 1; s <= speGroupCount;s++ )
                {
                    string name = ChangeHope.WebPage.PageRequest.GetFormString("SpecificationsName" + s);
                    string value = Request.Form["SpecificationsValue" + s];
                    if (specificationsData != string.Empty)
                    {
                        specificationsData += "g_space" + name + "n_v_space" + value;
                    }
                    else
                    {
                        specificationsData = name + "n_v_space" + value;
                    }
                }
                model.pro_Specifications = specificationsData;
            }
            #endregion
            if (ViewState["ID"] != null)
            {
                YXShop.Common.PromptInfo.Popedom("001008004", "对不起，您没有编辑权限");
                if (dt.Rows.Count > 0 && this.txtItemNo.Text.Trim() != this.hfItemNo.Value)
                {
                    ChangeHope.WebPage.BasePage.PageError("操作失败，商品编号（货号）不能重复。", "product_info_edit.aspx?putoutType=" + putoutType);
                    return;
                }
                model.pro_ID = Convert.ToInt32(ViewState["ID"].ToString());
                string AlbumInfo = Album(ImagesThumbnailsWidth, ImagesThumbnailsHeight, WhetherWater, ImageWatermarkTransparent, TextWatermarkTransparent, WatermarkPosition, WatermarkImage, WatermarkText, TextOrImagesWatermark, true, Convert.ToInt32(ViewState["ID"].ToString()));
                string reStr = string.Empty;
                if (bll.Update(model) > 0)
                {
                    reStr += this.SaveSpecifications(Convert.ToInt32(ViewState["ID"].ToString()), true);
                    reStr += this.SaveSparepart(Convert.ToInt32(ViewState["ID"].ToString()), true);
                }
                ChangeHope.WebPage.BasePage.PageRight("操作成功，您的已修改该商品信息。", "product_list.aspx?q_PutoutType=" + putoutType + "", "<li>" + reStr + "</li>");
            }
            else
            {
                YXShop.Common.PromptInfo.Popedom("001008002", "对不起，您没有新增权限");
                if (dt.Rows.Count > 0)
                {
                    ChangeHope.WebPage.BasePage.PageError("操作失败，商品编号（货号）不能重复。", "product_info_edit.aspx?putoutType=" + putoutType);
                    return;
                }
                string AlbumInfo = Album(ImagesThumbnailsWidth, ImagesThumbnailsHeight, WhetherWater, ImageWatermarkTransparent, TextWatermarkTransparent, WatermarkPosition, WatermarkImage, WatermarkText, TextOrImagesWatermark, false, 0);
                int productId=bll.Add(model);
                string reStr = string.Empty;
                if (productId > 0)
                {
                    reStr += this.SaveSpecifications(productId,false);
                    reStr += this.SaveSparepart(productId,false);
                    ChangeHope.WebPage.BasePage.PageRight("操作成功，您的添加的商品信息已保存。", "product_info_edit.aspx?putoutType=" + putoutType, "<li>" + reStr + "</li>");
                }
                else
                {
                    ChangeHope.WebPage.BasePage.PageError("操作失败，您的添加的商品信息保存失败。", "product_info_edit.aspx?putoutType=" + putoutType, "<li>" + reStr + "</li>");
                }
            }
        }
       

        #region 商品货号
        /// <summary>
        /// 商品货号
        /// </summary>
        /// <returns></returns>
        private string GoodsNO()
        {
            string reStr = string.Empty;
            reStr = "G"+System.DateTime.Now.ToString("yyyyMMddHHmmss");
            return reStr+=ChangeHope.Common.DEncryptHelper.GetRandWord(6);
        }
        #endregion

        #region 保存商品规格
        /// <summary>
        /// 保存商品规格
        /// </summary>
        /// <param name="ProductId"></param>
        /// <returns></returns>
        private string SaveSpecifications(int ProductId, bool IsAmend)
        {

            int count = 0;
            YXShop.BLL.Product.ProductSpecification bll = new YXShop.BLL.Product.ProductSpecification();
            YXShop.Model.Product.ProductSpecification model = new YXShop.Model.Product.ProductSpecification();
            if (IsAmend)
            {
                bll.DeleteSpecificationProduct(ProductId);
            }
            int specificationRows = ChangeHope.WebPage.PageRequest.GetFormInt("SpecificationRows");
            for (int i = 0; i < specificationRows; i++)
            {
                int speValRows = ChangeHope.WebPage.PageRequest.GetFormInt("SpeValRows" + i);
                if (speValRows > -1)
                {
                    string speItemNo = ChangeHope.WebPage.PageRequest.GetFormString("SpeItemNo" + speValRows) != "" ? ChangeHope.WebPage.PageRequest.GetFormString("SpeItemNo" + speValRows) : this.GoodsNO();
                    string speStock = ChangeHope.WebPage.PageRequest.GetFormString("SpeStock" + speValRows);
                    string speIntegral = ChangeHope.WebPage.PageRequest.GetFormString("SpeIntegral" + speValRows);
                    string speShopPrice = ChangeHope.WebPage.PageRequest.GetFormString("SpeShopPrice" + speValRows);
                    string memberPrice = ChangeHope.WebPage.PageRequest.GetFormString("SpeMemberPrice" + speValRows);
                    model.IntegralToBuy = speIntegral != "" ? Convert.ToDecimal(speIntegral) : 0;
                    model.MemberPrice = memberPrice;
                    model.ProductCode = speItemNo+"-"+i;
                    model.ProductId = ProductId;
                    model.ProductStock = speStock != "" ? Convert.ToInt32(speStock) : 0;
                    model.SalePrice = speShopPrice != "" ? Convert.ToDecimal(speShopPrice) : 0;
                    model.Specifications = ChangeHope.WebPage.PageRequest.GetFormString("SpeValue" + speValRows);
                    if (bll.Add(model) > 0)
                    {
                        count++;
                    }
                }
            }
            return "成功添加" + count + "条规格信息。";
        }
        #endregion

        #region 获取属性值
        /// <summary>
        /// 获取属性值
        /// </summary>
        /// <returns></returns>
        protected string PropertyValue()
        {
            string Pro_PValues = string.Empty;
            string parmTemp = ChangeHope.WebPage.PageRequest.GetFormString("ProPropertyID");
            if (parmTemp.IndexOf(",") > -1)
            {
                foreach (string pTemp in parmTemp.Split(','))
                {
                    string PropertyDataValue = ChangeHope.WebPage.PageRequest.GetFormString("property" + pTemp);
                    string PropertyDataID = pTemp;
                    if (!string.IsNullOrEmpty(PropertyDataValue))
                    {
                        Pro_PValues += PropertyDataID + "va_space" + PropertyDataValue + "gro_space";
                    }
                }
            }
            else
            {
                string PropertyDataValue = ChangeHope.WebPage.PageRequest.GetFormString("property" + parmTemp);
                string PropertyDataID = parmTemp;
                if (!string.IsNullOrEmpty(PropertyDataValue))
                {
                    Pro_PValues += PropertyDataID + "va_space" + PropertyDataValue + "gro_space";
                }
            }
            return Pro_PValues;
        }
        #endregion

        #region 获取商品参数
        /// <summary>
        /// 获取商品参数
        /// </summary>
        /// <returns></returns>
        protected string ParameterValue()
        {
            string reStr = string.Empty;
            string Pro_PValues = string.Empty;
            string parTypeId = ChangeHope.WebPage.PageRequest.GetFormString("ProParameterTypeID");
            foreach (string parTy in parTypeId.Split(','))
            {
                string parmTemp = ChangeHope.WebPage.PageRequest.GetFormString("ProParameterID" + parTy);
                if (parmTemp.IndexOf(",") > -1)
                {
                    foreach (string pTemp in parmTemp.Split(','))
                    {
                        string PropertyDataValue = ChangeHope.WebPage.PageRequest.GetFormString("parameter" + parTy + pTemp);
                        string PropertyDataID = pTemp;
                        if (!string.IsNullOrEmpty(PropertyDataValue))
                        {
                            if (Pro_PValues != string.Empty)
                            {
                                Pro_PValues += "|" + PropertyDataID + "," + PropertyDataValue;
                            }
                            else
                            {
                                Pro_PValues = PropertyDataID + "," + PropertyDataValue;
                            }
                        }
                    }
                }
                else
                {
                    string PropertyDataValue = ChangeHope.WebPage.PageRequest.GetFormString("parameter" + parTy + parmTemp);
                    string PropertyDataID = parmTemp;
                    if (!string.IsNullOrEmpty(PropertyDataValue))
                    {
                        if (Pro_PValues != string.Empty)
                        {
                            Pro_PValues += "|" + PropertyDataID + "," + PropertyDataValue;
                        }
                        else
                        {
                            Pro_PValues = PropertyDataID + "," + PropertyDataValue;
                        }
                    }
                }
                if (reStr != string.Empty)
                {
                    reStr += parTy + "tid_space" + Pro_PValues + "t_space";
                }
                else
                {
                    reStr = parTy + "tid_space" + Pro_PValues + "t_space";
                }
            }
            return reStr;
        }
        #endregion

        #region 保存商品配件
        /// <summary>
        /// 保存商品配件
        /// </summary>
        /// <param name="ProductId"></param>
        /// <returns></returns>
        private string SaveSparepart(int ProductId,bool IsAmend)
        {
            YXShop.BLL.Product.ProductSparepart bll = new YXShop.BLL.Product.ProductSparepart();
            YXShop.Model.Product.ProductSparepart model = new YXShop.Model.Product.ProductSparepart();
            if (IsAmend)
            {
                bll.DeleteProductSparepart(ProductId);
            }
            int sparepartGroupCount =Convert.ToInt32(this.hfSparepartGroup.Value.Trim());
            int count = 0;
            for (int i = 1; i <= sparepartGroupCount; i++)
            {
                int sparepartRows = ChangeHope.WebPage.PageRequest.GetFormInt("hfSparepartId");
                if (sparepartRows > -1)
                {
                    model.ProductId = ProductId;
                    model.SparepartName = ChangeHope.WebPage.PageRequest.GetFormString("txtSparepartName" + sparepartRows);
                    model.SparepartProduct = ChangeHope.WebPage.PageRequest.GetFormString("hfProductSparepartID" + sparepartRows);
                    model.FavourableType = ChangeHope.WebPage.PageRequest.GetFormInt("SparepartFavourable" + sparepartRows);
                    model.FavourableLimit = Convert.ToDecimal(ChangeHope.WebPage.PageRequest.GetFormString("txtFavourablePrice" + sparepartRows));
                    model.BuyMaxCount = ChangeHope.WebPage.PageRequest.GetFormInt("txtMaxCount" + sparepartRows);
                    model.BuyMinCount = ChangeHope.WebPage.PageRequest.GetFormInt("txtMinCount" + sparepartRows);
                    bll.Add(model); 
                    count++;
                }
            }
            return "成功添加" + count + "组配件信息。";
        }
        #endregion

        #region 商品相册
        /// <summary>
        /// 上传商品相册图
        /// </summary>
        /// <param name="albumthumbnail"></param>
        /// <param name="ImagesThumbnailsWidth"></param>
        /// <param name="ImagesThumbnailsHeight"></param>
        /// <param name="WhetherWater"></param>
        /// <param name="ImageWatermarkTransparent"></param>
        /// <param name="TextWatermarkTransparent"></param>
        /// <param name="WatermarkPosition"></param>
        /// <param name="WatermarkImage"></param>
        /// <param name="WatermarkText"></param>
        /// <param name="TextOrImagesWatermark"></param>
        protected string Album(int ImagesThumbnailsWidth, int ImagesThumbnailsHeight, bool WhetherWater, int ImageWatermarkTransparent, int TextWatermarkTransparent, string WatermarkPosition, string WatermarkImage, string WatermarkText, string TextOrImagesWatermark, bool IsModfiy, int ProductId)
        {
            YXShop.Common.SysParameter sp = new YXShop.Common.SysParameter();
            string gomessage = "";
            int proId = 0;
            YXShop.BLL.Product.ProductInfo bll = new YXShop.BLL.Product.ProductInfo();
            if (IsModfiy)
            {
                proId = ProductId;
            }
            else
            {
                if (bll.GetMax() == 0)
                {
                    return gomessage = "相册上传失败";
                }
                else
                {
                    proId = bll.GetMax() + 1;
                }
            }
            System.Web.HttpFileCollection files = System.Web.HttpContext.Current.Request.Files;
            YXShop.BLL.Product.ProductAlbum pabll = new YXShop.BLL.Product.ProductAlbum();
            YXShop.Model.Product.ProductAlbum pamodel = new YXShop.Model.Product.ProductAlbum();
            string[] rd = null;
            string des = ChangeHope.WebPage.PageRequest.GetFormString("description");
            if (!string.IsNullOrEmpty(des))
            {
                rd = des.Split(',');//获得图片描述的文本框字符串数组，为对应的图片的描述
            }
            if (files.Count > 2)//说明图片大小和格式都没问题
            {
                YXShop.BLL.Product.ProductAlbum PGBLL = new YXShop.BLL.Product.ProductAlbum();
                YXShop.Model.Product.ProductAlbum PGModel = new YXShop.Model.Product.ProductAlbum();
                int autouFile = 0;
                if (cbBreviary.Checked)//如果自动生成缩略图被选中，那么商品相册的fileupload集合从索引1开始计算，否则从2开始计算
                {
                    autouFile = files.Count;
                }
                else
                {
                    autouFile = files.Count;
                }
                ChangeHope.Common.UploadProcesedImages wm = new ChangeHope.Common.UploadProcesedImages();
                ChangeHope.Common.UploadFile uf = new ChangeHope.Common.UploadFile();
                string AlbumThumbnailSave = "/yxuploadfile/product/albumthumbnail";
                string AlbumOriginalSave = "/yxuploadfile/product/albumoriginal";
                string AlbumThumbnail = string.Empty;
                string AlbumOriginal = string.Empty;
                string Message = string.Empty;
                uf.ExtensionLim = ".gif,.jpg,.jpeg,.bmp";
                uf.FileLengthLim = sp.ImageSize;
                for (int i = 2; i < files.Count; i++)
                {
                    uf.MyFile = files[i];
                    uf.SavePath = AlbumOriginalSave;
                    if (uf.HTMLUpLoad())
                    {
                        if (uf.HaveLoad)
                        {
                            AlbumOriginal = uf.FilePath;
                            //原图缩略图
                            wm.SourceImagePath = AlbumOriginal;
                            wm.ThumbnailImagePath = AlbumOriginalSave;
                            wm.ThumbnailImageWidth = ImagesThumbnailsWidth;
                            wm.ThumbnailImageHeight = ImagesThumbnailsHeight;
                            if (wm.ToThumbnailImage())
                            {
                                AlbumThumbnail = wm.FilePath;
                            }
                            else
                            {
                                gomessage += "<br>" + wm.Message;

                            }


                        }
                        else
                        {
                            gomessage += "<br>" + uf.Message;
                        }
                        if (WhetherWater)
                        {
                            //原图水印
                            if (!string.IsNullOrEmpty(AlbumOriginal))
                            {
                                wm.SourceImagePath = AlbumOriginal;
                                wm.ImageDeaphaneity = float.Parse(ImageWatermarkTransparent.ToString());
                                wm.Diaphaneity = TextWatermarkTransparent;
                                switch (WatermarkPosition)
                                {
                                    case "1":
                                        wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.LeftTop;
                                        break;
                                    case "2":
                                        wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.LeftBottom;
                                        break;
                                    case "3":
                                        wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.RightTop;
                                        break;
                                    case "4":
                                        wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.RightBottom;
                                        break;
                                    case "5":
                                        wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.CenterTop;
                                        break;
                                    case "9":
                                        wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.Center;
                                        break;
                                    case "7":
                                        wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.CenterBottom;
                                        break;
                                }
                                if (TextOrImagesWatermark == "0")
                                {
                                    //图片水印
                                    if (!string.IsNullOrEmpty(WatermarkImage))
                                    {
                                        wm.WaterMarkImagePath = WatermarkImage;
                                    }
                                    else
                                    {
                                        gomessage += "<br>" + "操作失败，上传图片水印失败，请确认系统设置水印图片是否存在。";
                                    }
                                }
                                else
                                {
                                    //文字水印
                                    if (!string.IsNullOrEmpty(WatermarkText))
                                    {
                                        wm.WaterMarkText = WatermarkText;
                                    }
                                    else
                                    {
                                        gomessage += "<br>" + "操作失败，上传图片水印失败，请确认系统设置水印文字是否存在。";
                                    }
                                }
                                wm.SaveWaterMarkImagePath = AlbumOriginalSave;
                                if (wm.ToWaterMark())
                                {
                                    AlbumOriginal = wm.FilePath;
                                }
                                else
                                {
                                    gomessage += "<br>" + "操作失败，" + wm.Message + "";
                                }
                            }
                            //原图缩略图水印
                            if (!string.IsNullOrEmpty(AlbumThumbnail))
                            {
                                wm.SourceImagePath = AlbumThumbnail;
                                wm.ImageDeaphaneity = float.Parse(ImageWatermarkTransparent.ToString());
                                wm.Diaphaneity = TextWatermarkTransparent;
                                switch (WatermarkPosition)
                                {
                                    case "1":
                                        wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.LeftTop;
                                        break;
                                    case "2":
                                        wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.LeftBottom;
                                        break;
                                    case "3":
                                        wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.RightTop;
                                        break;
                                    case "4":
                                        wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.RightBottom;
                                        break;
                                    case "5":
                                        wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.CenterTop;
                                        break;
                                    case "9":
                                        wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.Center;
                                        break;
                                    case "7":
                                        wm.WaterMarkAlign = ChangeHope.Common.ImageAlign.CenterBottom;
                                        break;
                                }
                                if (TextOrImagesWatermark == "0")
                                {
                                    //图片水印
                                    if (!string.IsNullOrEmpty(WatermarkImage))
                                    {
                                        wm.WaterMarkImagePath = WatermarkImage;
                                    }
                                    else
                                    {
                                        gomessage += "<br>" + "操作失败，上传图片水印失败，请确认系统设置水印图片是否存在。";
                                    }
                                }
                                else
                                {
                                    //文字水印
                                    if (!string.IsNullOrEmpty(WatermarkText))
                                    {
                                        wm.WaterMarkText = WatermarkText;
                                    }
                                    else
                                    {
                                        gomessage += "<br>" + "操作失败，上传图片水印失败，请确认系统设置水印文字是否存在。";
                                    }
                                }
                                wm.SaveWaterMarkImagePath = AlbumThumbnailSave;
                                if (wm.ToWaterMark())
                                {
                                    AlbumThumbnail = wm.FilePath;
                                }
                                else
                                {
                                    gomessage += "<br>" + "操作失败，" + wm.Message + "";
                                }
                            }

                        }
                    }
                    pamodel.Productid = proId;
                    pamodel.OriginalAddress = AlbumOriginal;
                    pamodel.ThumbnailAddress = AlbumThumbnail;
                    pamodel.Description = "";
                    if (AlbumThumbnail != string.Empty)
                    {
                        pabll.Add(pamodel);
                    }
                }

            }
            return gomessage;
        }
        #endregion
        #endregion


    }
}
